﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace SeniorEventArgs
{
    class MyArgs
    {
        public int attack =0;
        public bool poisoned =false;
        public bool headache=false;
    }
    class Player
    {
        public event EventHandler<MyArgs> OnAttack=null;
        //这里制定事件
        public void DoAoe()
        {
            MyArgs args = new MyArgs();
            args.attack = 10;
            args.poisoned = true;
            args.headache = true;
            if(OnAttack!=null) OnAttack(this , args);
        }
    }
    //在enemy里订阅攻击事件
    class Enemy
    {
        private int blood = 100;
        public void AttackMe(object sender, MyArgs args)
        {
            Console.WriteLine("我被攻击了！-"+args.attack);
            Console.WriteLine("是否中毒："+args.poisoned);
            Console.WriteLine("是否头晕："+args.headache);
        }
        public void ShowBlood(object sender, MyArgs args)
        {
            blood-=(int)args.attack;
            Console.WriteLine($"还剩{blood}血");
        }
    }

    internal class Program
    {
        static void Main(string[] args)
        {
            Player player = new Player();
            Enemy enemy = new Enemy();
            player.OnAttack += enemy.AttackMe;
            player.OnAttack += enemy.ShowBlood;
            player.DoAoe();
            Console.Read();
        }
    }
}
